<?php 
require_once BASE_PATH.'application/models/basedao'.EXT;

class permisoDAO extends baseDAO {
	
    var $table = 'permisos';
    var $id    = '';

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    
    function findByRolK($id,$data= array()){ 
	$this->_sql($data);
    	return $this->findByColumn("rol_k",array($id));
    }
    
    function getAccionesByRolK($rol_k)
    {
	$this->db->select("modulos_acciones.*,".$this->table.".rol_k,modulos.modulo_padre_k");
	$this->db->from($this->table);
	$this->db->join('modulos_acciones', 'modulos_acciones.modulo_accion_k = '.$this->table.'.modulo_accion_k');
	$this->db->join('modulos', 'modulos.modulo_k = modulos_acciones.modulo_k');
	$this->db->where($this->table.'.rol_k',$rol_k);
	
	$query = $this->db->get();
	return $query->result();
    }
    
    
    function getModulosByRolK($rol_k)
    {
	$this->db->select("modulos.*");
	$this->db->from($this->table);
	$this->db->join('modulos_acciones', 'modulos_acciones.modulo_accion_k = '.$this->table.'.modulo_accion_k');
	$this->db->join('modulos', 'modulos.modulo_k = modulos_acciones.modulo_k');
	$this->db->where($this->table.'.rol_k',$rol_k);
	
	$this->db->group_by("modulo_k"); 
	
	$query = $this->db->get();
	return $query->result();
    }
    
    
    function getMenuByRolK($rol_k){
	$modulos = $this->getModulosByRolK($rol_k);
    }
    
}
?>